/**	
 * Author : Mht
 * Desc : For 2016 RDM 
 */
package configuration;

import lombok.extern.log4j.Log4j;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import;

import common.aop.LogAspect;

/**
 * @author Mht
 * @date May 27, 2016
 */
@Log4j
@Configuration
@EnableAutoConfiguration
@EnableAspectJAutoProxy(proxyTargetClass=true)
@ComponentScan({ "service" })
@ServletComponentScan({ "servlet" })
@Import({ SettingConfiguraion.class, SpringMVCConfiguration.class, RedisConfiguration.class })
public class Application extends SpringBootServletInitializer implements EmbeddedServletContainerCustomizer {

	public Application() {
		log.info("[Initialize Spring Application]");
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(Application.class);
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@Override
	public void customize(ConfigurableEmbeddedServletContainer container) {
		container.setPort(8090);
		container.setSessionTimeout(30);
	}

//	@Bean
//	public ServletRegistrationBean servletRegistrationBean() {
//		return new ServletRegistrationBean(new MenuCoreServlet(), "/menu/*");
//	}
	
	@Bean
	public LogAspect logAspect(){
		return new LogAspect();
	}
}
